/**
 * Created by Dalyn on 2017/5/8.
 */
import React from "react";
import {hashHistory} from 'react-router';
import Relay from "react-relay";
import { Table, Icon, Popconfirm, message } from 'antd';
import {Button} from 'fly';

import ReactKey from "../../../../util/ReactKey";
import ProductionNumberDetail from '../mutation/ProductionNumberMutation/ProductNumberListMutation';
import SaveProNumDetailMutation from '../mutation/ProductionNumberMutation/SaveProNumDetailMutation';
import "../css/productionLicense_index.css";
import "../css/productionNumberDetail.css";
import "../../css/productionManagement_common.css";
import AddImgModal from "./AddImgModal";

const { Column, ColumnGroup } = Table;
/*导出组件*/
export default class ProductionColour extends React.Component{
    constructor(props) {
        super(props);
        this.state = {
          dataSource: [],
          proNumIds: [],
          context:{},
          loading: true,
        };
        this.numberDetailIds = []
    }

    componentWillMount(){
      this.getProductNumberList();
    }

    //获取数据列表
    getProductNumberList() {
      Relay.Store.commitUpdate(
          new ProductionNumberDetail({
            pdId: this.props.pdId
          }),
          {
              onFailure: () => {
                  message.error("网络请求失败")
                  this.setState({
                    loading: false
                  })
              },
              onSuccess: (response) => {
                 let errorCode = response.getProNumDetailList.responseData.errorCode
                 if (errorCode == 0) {
                   let proNumDetailModelList = response.getProNumDetailList.responseData.proNumDetailModelList
                   if (!proNumDetailModelList.length) {
                     proNumDetailModelList.push({
                         pdId: this.props.pdId || null,
                         add2XL: null,
                         add3XL: null,
                         add4XL: null,
                         add5XL: null,
                         addL: null,
                         addM: null,
                         addS: null,
                         addXL: null,
                         addXS: null,
                         colour: null,
                         compact5XL: null,
                         compact4XL: null,
                         compact3XL: null,
                         compact2XL: null,
                         compactXL: null,
                         compactL: null,
                         compactS: null,
                         compactXS: null,
                         compactM: null,
                         numberDetailId:ReactKey.key
                     },{sum: 1})
                   } else {
                     proNumDetailModelList.push({sum: 1})
                   }
                   this.setState({
                     dataSource: proNumDetailModelList,
                     loading: false
                   })
                 } else if(errorCode == 500){
                   message.error('服务器错误，请联系系统管理员')
                 }
              }
          }
      );
    }
    //保存数据
    SaveNumberClick(){
        let newData = [];
        let dataSource = this.state.dataSource;
        dataSource.pop()
        dataSource.map((v, i)=>{
            if (v.numberDetailId != null && v.itemTotal == 0 && (v.imgURL == '' || v.imgURL == null) && (v.colour == ''|| v.colour == null)  && (v.remark == '' || v.remark == null)){
              this.numberDetailIds.push(v.numberDetailId)

            } else if ( (v.itemTotal != 0 && v.itemTotal != undefined && v.itemTotal != '') || v.imgURL != '' || v.colour != ''  || v.remark != '' ){
                  let Json = {
                    pdId: this.props.pdId || null,
                    numberDetailId: v.numberDetailId || null,
                    add2XL: v.add2XL,
                    add3XL: v.add3XL,
                    add4XL: v.add4XL,
                    add5XL: v.add5XL,
                    addL: v.addL,
                    addM: v.addM,
                    addS: v.addS,
                    addXL: v.addXL,
                    addXS: v.addXS,
                    compact5XL: v.compact5XL,
                    compact4XL: v.compact4XL,
                    compact3XL: v.compact3XL,
                    compact2XL: v.compact2XL,
                    compactXL: v.compactXL,
                    compactL: v.compactL,
                    compactS: v.compactS,
                    compactXS: v.compactXS,
                    compactM: v.compactM,
                    colour: v.colour,
                    remark: v.remark,
                    imgURL: v.imgURL
                  }
                  newData.push(Json)
            }
        })
        this.setState({
          proNumIds: this.numberDetailIds
        },()=>{
          Relay.Store.commitUpdate(
              new SaveProNumDetailMutation({
                proNumIds: this.state.proNumIds.join(','),
                proNumDetailsJSON: JSON.stringify(newData)
              }),
              {
                  onFailure: () => {
                      message.error("请求失败")
                  },
                  onSuccess: (response) => {
                     let errorCode = response.saveProNumDetail.responseData.errorCode
                     if (errorCode == 0) {
                       message.success('保存成功')
                       this.setState({
                         dataSource: [],
                         proNumIds: [],
                         loading: true
                       })
                       newData = []
                       this.numberDetailIds = []
                       this.getProductNumberList()
                     } else if (errorCode == 500) {
                       message.error('服务器错误,请联系系统管理员')
                     }
                  }
              }
          );
        });
    }
    //监听所有input改变
    InputChange(type,index,e){
      let text = e.target.value;
      let rulenum = /^\d{0,10}$/;
      if (!rulenum.test(e.target.value) && type != 'colour' && type != 'remark') {
        return
      }
      let dataSource = this.state.dataSource;
      if(!dataSource[index]){
        dataSource[index] = {}
      }
      let context = dataSource[index];

      if (type == 'remark' || type == 'colour' ) {
        let str_temp = text.replace(/[\u4e00-\u9fa5]/g, 'aa')//将汉字替换为aa
        if (str_temp.length > 50) {
          e.target.value = text.toString(0,50)
          return
        }
      }

      if ( type != 'colour' && type != 'remark' && type != 'imgURL') {
        context[type] = text.toString().substring(0,10)
      } else {
        context[type] = text
      }
      if(type == 'addXS' && context.addXS != undefined) {
        context.totalXS = Number(text || 0) + Number(context.compactXS || 0)
        context.itemTotal = Number(context.totalS || 0)+ Number(context.totalXS || 0)+ Number(context.totalM || 0)+ Number(context.totalL || 0)+Number(context.totalXL || 0)+Number(context.total2XL || 0)+Number(context.total3XL || 0)+Number(context.total4XL || 0)+Number(context.total5XL || 0)
      } else  if(type == 'addS' && context.addS != undefined) {
        context.totalS = Number(text || 0) + Number(context.compactS || 0)
        context.itemTotal = Number(context.totalS || 0)+ Number(context.totalXS || 0)+ Number(context.totalM || 0)+ Number(context.totalL || 0)+Number(context.totalXL || 0)+Number(context.total2XL || 0)+Number(context.total3XL || 0)+Number(context.total4XL || 0)+Number(context.total5XL || 0)
      } else  if(type == 'addM' && context.addM != undefined) {
        context.totalM = Number(text || 0) + Number(context.compactM || 0)
        context.itemTotal = Number(context.totalS || 0)+ Number(context.totalXS || 0)+ Number(context.totalM || 0)+ Number(context.totalL || 0)+Number(context.totalXL || 0)+Number(context.total2XL || 0)+Number(context.total3XL || 0)+Number(context.total4XL || 0)+Number(context.total5XL || 0)
      } else  if(type == 'addL' && context.addL != undefined) {
        context.totalL = Number(text || 0) + Number(context.compactL || 0)
        context.itemTotal = Number(context.totalS || 0)+ Number(context.totalXS || 0)+ Number(context.totalM || 0)+ Number(context.totalL || 0)+Number(context.totalXL || 0)+Number(context.total2XL || 0)+Number(context.total3XL || 0)+Number(context.total4XL || 0)+Number(context.total5XL || 0)
      } else  if(type == 'addXL' && context.addXL != undefined) {
        context.totalXL = Number(text || 0) + Number(context.compactXL || 0)
        context.itemTotal = Number(context.totalS || 0)+ Number(context.totalXS || 0)+ Number(context.totalM || 0)+ Number(context.totalL || 0)+Number(context.totalXL || 0)+Number(context.total2XL || 0)+Number(context.total3XL || 0)+Number(context.total4XL || 0)+Number(context.total5XL || 0)
      } else  if(type == 'add2XL' && context.add2XL != undefined) {
        context.total2XL = Number(text || 0) + Number(context.compact2XL || 0)
        context.itemTotal = Number(context.totalS || 0)+ Number(context.totalXS || 0)+ Number(context.totalM || 0)+ Number(context.totalL || 0)+Number(context.totalXL || 0)+Number(context.total2XL || 0)+Number(context.total3XL || 0)+Number(context.total4XL || 0)+Number(context.total5XL || 0)
      } else  if(type == 'add3XL' && context.add3XL != undefined) {
        context.total3XL = Number(text || 0) + Number(context.compact3XL || 0)
        context.itemTotal = Number(context.totalS || 0)+ Number(context.totalXS || 0)+ Number(context.totalM || 0)+ Number(context.totalL || 0)+Number(context.totalXL || 0)+Number(context.total2XL || 0)+Number(context.total3XL || 0)+Number(context.total4XL || 0)+Number(context.total5XL || 0)
      } else  if(type == 'add4XL' && context.add4XL != undefined) {
        context.total4XL = Number(text || 0) + Number(context.compact4XL || 0)
        context.itemTotal = Number(context.totalS || 0)+ Number(context.totalXS || 0)+ Number(context.totalM || 0)+ Number(context.totalL || 0)+Number(context.totalXL || 0)+Number(context.total2XL || 0)+Number(context.total3XL || 0)+Number(context.total4XL || 0)+Number(context.total5XL || 0)
      } else  if(type == 'add5XL' && context.add5XL != undefined) {
        context.total5XL = Number(text || 0) + Number(context.compact5XL || 0)
        context.itemTotal = Number(context.totalS || 0)+ Number(context.totalXS || 0)+ Number(context.totalM || 0)+ Number(context.totalL || 0)+Number(context.totalXL || 0)+Number(context.total2XL || 0)+Number(context.total3XL || 0)+Number(context.total4XL || 0)+Number(context.total5XL || 0)
      } else  if(type == 'compactXS' && context.compactXS != undefined) {
        context.totalXS = Number(text || 0) + Number(context.addXS || 0)
        context.itemTotal = Number(context.totalS || 0)+ Number(context.totalXS || 0)+ Number(context.totalM || 0)+ Number(context.totalL || 0)+Number(context.totalXL || 0)+Number(context.total2XL || 0)+Number(context.total3XL || 0)+Number(context.total4XL || 0)+Number(context.total5XL || 0)
      } else  if(type == 'compactS' && context.compactS != undefined) {
        context.totalS = Number(text || 0) + Number(context.addS || 0)
        context.itemTotal = Number(context.totalS || 0)+ Number(context.totalXS || 0)+ Number(context.totalM || 0)+ Number(context.totalL || 0)+Number(context.totalXL || 0)+Number(context.total2XL || 0)+Number(context.total3XL || 0)+Number(context.total4XL || 0)+Number(context.total5XL || 0)
      } else  if(type == 'compactM' && context.compactM != undefined) {
        context.totalM = Number(text || 0) + Number(context.addM || 0)
        context.itemTotal = Number(context.totalS || 0)+ Number(context.totalXS || 0)+ Number(context.totalM || 0)+ Number(context.totalL || 0)+Number(context.totalXL || 0)+Number(context.total2XL || 0)+Number(context.total3XL || 0)+Number(context.total4XL || 0)+Number(context.total5XL || 0)
      } else  if(type == 'compactL' && context.compactL != undefined) {
        context.totalL = Number(text || 0) + Number(context.addL || 0)
        context.itemTotal = Number(context.totalS || 0)+ Number(context.totalXS || 0)+ Number(context.totalM || 0)+ Number(context.totalL || 0)+Number(context.totalXL || 0)+Number(context.total2XL || 0)+Number(context.total3XL || 0)+Number(context.total4XL || 0)+Number(context.total5XL || 0)
      } else  if(type == 'compactXL' && context.compactXL != undefined) {
        context.totalXL = Number(text || 0) + Number(context.addXL || 0)
        context.itemTotal = Number(context.totalS || 0)+ Number(context.totalXS || 0)+ Number(context.totalM || 0)+ Number(context.totalL || 0)+Number(context.totalXL || 0)+Number(context.total2XL || 0)+Number(context.total3XL || 0)+Number(context.total4XL || 0)+Number(context.total5XL || 0)
      } else  if(type == 'compact2XL' && context.compact2XL != undefined) {
        context.total2XL = Number(text || 0) + Number(context.add2XL || 0)
        context.itemTotal = Number(context.totalS || 0)+ Number(context.totalXS || 0)+ Number(context.totalM || 0)+ Number(context.totalL || 0)+Number(context.totalXL || 0)+Number(context.total2XL || 0)+Number(context.total3XL || 0)+Number(context.total4XL || 0)+Number(context.total5XL || 0)
      } else  if(type == 'compact3XL' && context.compact3XL != undefined) {
        context.total3XL = Number(text || 0) + Number(context.add3XL || 0)
        context.itemTotal = Number(context.totalS || 0)+ Number(context.totalXS || 0)+ Number(context.totalM || 0)+ Number(context.totalL || 0)+Number(context.totalXL || 0)+Number(context.total2XL || 0)+Number(context.total3XL || 0)+Number(context.total4XL || 0)+Number(context.total5XL || 0)
      } else  if(type == 'compact4XL' && context.compact4XL != undefined) {
        context.total4XL = Number(text || 0) + Number(context.add4XL || 0)
        context.itemTotal = Number(context.totalS || 0)+ Number(context.totalXS || 0)+ Number(context.totalM || 0)+ Number(context.totalL || 0)+Number(context.totalXL || 0)+Number(context.total2XL || 0)+Number(context.total3XL || 0)+Number(context.total4XL || 0)+Number(context.total5XL || 0)
      } else  if(type == 'compact5XL' && context.compact5XL != undefined) {
        context.total5XL = Number(text || 0) + Number(context.add5XL || 0)
        context.itemTotal = Number(context.totalS || 0)+ Number(context.totalXS || 0)+ Number(context.totalM || 0)+ Number(context.totalL || 0)+Number(context.totalXL || 0)+Number(context.total2XL || 0)+Number(context.total3XL || 0)+Number(context.total4XL || 0)+Number(context.total5XL || 0)
      }

      this.setState({
          context: context,
          dataSource: dataSource
      });

    }
    //删除按钮删除一行
    onDelete = (index,proNumIds) => {
      const dataSource = [...this.state.dataSource];
      dataSource.splice(index, 1);
      if (proNumIds) {
        this.numberDetailIds.push(proNumIds)
        this.setState({
          proNumIds: this.numberDetailIds
        })
      }
      this.setState({
        dataSource,
      });

    }
    //点击添加按钮添加一行
    handleAdd = () => {
      const { dataSource } = this.state;
      const newData = {
          pdId: this.props.pdId || null,
          add2XL: null,
          add3XL: null,
          add4XL: null,
          add5XL: null,
          addL: null,
          addM: null,
          addS: null,
          addXL: null,
          addXS: null,
          colour: null,
          compact5XL: null,
          compact4XL: null,
          compact3XL: null,
          compact2XL: null,
          compactXL: null,
          compactL: null,
          compactS: null,
          compactXS: null,
          compactM: null,
          remark: null,
          imgURL: null,
          numberDetailId:ReactKey.key
      };
      dataSource.splice(dataSource.length -1, 0, newData )
      this.setState({
        dataSource
      });
    }
    //合同数总和
    numberSum(type) {
      let numberSum = 0
      this.state.dataSource.map((v, i, ele)=>{
        if(type == 'addXS' && v.addXS != undefined) {
          numberSum+=Number(v.addXS)
          return numberSum
        } else  if(type == 'addS' && v.addS != undefined) {
          numberSum+=Number(v.addS)
          return numberSum
        } else  if(type == 'addM' && v.addM != undefined) {
          numberSum+=Number(v.addM)
          return numberSum
        } else  if(type == 'addL' && v.addL != undefined) {
          numberSum+=Number(v.addL)
          return numberSum
        } else  if(type == 'addXL' && v.addXL != undefined) {
          numberSum+=Number(v.addXL)
          return numberSum
        } else  if(type == 'add2XL' && v.add2XL != undefined) {
          numberSum+=Number(v.add2XL)
          return numberSum
        } else  if(type == 'add3XL' && v.add3XL != undefined) {
          numberSum+=Number(v.add3XL)
          return numberSum
        } else  if(type == 'add4XL' && v.add4XL != undefined) {
          numberSum+=Number(v.add4XL)
          return numberSum
        } else  if(type == 'add5XL' && v.add5XL != undefined) {
          numberSum+=Number(v.add5XL)
          return numberSum
        } else  if(type == 'compactXS' && v.compactXS != undefined) {
          numberSum+=Number(v.compactXS)
          return numberSum
        } else  if(type == 'compactS' && v.compactS != undefined) {
          numberSum+=Number(v.compactS)
          return numberSum
        } else  if(type == 'compactM' && v.compactM != undefined) {
          numberSum+=Number(v.compactM)
          return numberSum
        } else  if(type == 'compactL' && v.compactL != undefined) {
          numberSum+=Number(v.compactL)
          return numberSum
        } else  if(type == 'compactXL' && v.compactXL != undefined) {
          numberSum+=Number(v.compactXL)
          return numberSum
        } else  if(type == 'compact2XL' && v.compact2XL != undefined) {
          numberSum+=Number(v.compact2XL)
          return numberSum
        } else  if(type == 'compact3XL' && v.compact3XL != undefined) {
          numberSum+=Number(v.compact3XL)
          return numberSum
        } else  if(type == 'compact4XL' && v.compact4XL != undefined) {
          numberSum+=Number(v.compact4XL)
          return numberSum
        } else  if(type == 'compact5XL' && v.compact5XL != undefined) {
          numberSum+=Number(v.compact5XL)
          return numberSum
        } else if(type == 'itemTotal' && v.itemTotal != undefined) {
          numberSum+=Number(v.itemTotal)
          return numberSum
        }
      })
      return numberSum
    }
    //显示上传图片弹框
    showimgmodal(index,imgURL){
        this.refs.addimg.setState({
            visible:true,
            index: index,
        });
    }
    //点击弹框确定之后url赋给src
    showImg(url,index){
        let dataSource = this.state.dataSource;
        if(!dataSource[index]){
            dataSource[index] = {}
        }
        let context = dataSource[index];
        context['imgURL'] =  url;
        this.refs.addimg.setState({
            visible:false,
        });
        this.setState({
          dataSource
        })
    }

    render(){
        return (
            <div className="poduction_manage_tab_box" >
                <Table
                  bordered
                  scroll={{ x: 3200  }}
                  pagination={false}
                  loading={this.state.loading}
                  rowKey={record => record.numberDetailId}
                  className='order_table'
                  dataSource = {this.state.dataSource}>
                   <Column
                    title="颜色"
                    dataIndex="colour"
                    key="colour"
                    width='100px'
                    fixed='left'
                    render= {(text, record, index) => {
                      if (record.sum == 1) {
                        return ''
                      } else {
                        return (<input title={record.colour} className="prodution_update_progress_input_edit"  value={record.colour} type="text" onChange={this.InputChange.bind(this,'colour',index)}/>)
                      }
                    }}
                  />
                   <Column
                    title="图片"
                    dataIndex="imgURL"
                    key="imgURL"
                    width='100px'
                    fixed='left'
                    render= {(text, record, index) => {
                      if (record.sum == 1) {
                        return '合计'
                      } else {
                         return (<img width="94" height='32' style={{height:32}} className="order_from_td_img_context" alt="+添加图片" src={record.imgURL} onClick={this.showimgmodal.bind(this, index, record.imgURL)}/>)
                      }
                    }}
                  />
                   <ColumnGroup title="XS">
                     <Column
                       title="合同数"
                       dataIndex="addXS"
                       key="addXS"
                       width='100px'
                       render= {(text, record, index) => {
                         if(record.sum == 1) {
                           return this.numberSum('addXS')
                         } else {
                           return (<input className="prodution_update_progress_input_edit production_number_detail_number" onChange={this.InputChange.bind(this,'addXS',index)}  type="number"  value={record.addXS}/>)
                         }
                       }}
                     />
                     <Column
                       title="加裁数"
                       dataIndex="compactXS"
                       key="compactXS"
                       width='100px'
                       render= {(text, record, index) => {
                         if(record.sum == 1) {
                           return this.numberSum('compactXS')
                         } else {
                            return (<input className="prodution_update_progress_input_edit production_number_detail_number" onChange={this.InputChange.bind(this,'compactXS',index)} type="number"  value={record.compactXS}/>)
                         }
                       }}
                     />
                     <Column
                       title="裁剪数"
                       dataIndex=""
                       key=""
                       width='100px'
                       render= {(text, record, index) => {
                         if(record.sum == 1) {
                           return this.numberSum('compactXS')+this.numberSum('addXS')
                         } else {
                           return Number(record.totalXS)  || 0
                         }
                       }}
                     />
                   </ColumnGroup>
                   <ColumnGroup title="S">
                     <Column
                       title="合同数"
                       dataIndex="addS"
                       key="addS"
                       width='100px'
                       render= {(text, record, index) => {
                         if(record.sum == 1) {
                           return this.numberSum('addS')
                         } else {
                            return (<input className="prodution_update_progress_input_edit production_number_detail_number" onChange={this.InputChange.bind(this,'addS',index)} type="number"  value={record.addS}/>)
                         }
                       }}
                     />
                     <Column
                       title="加裁数"
                       dataIndex="compactS"
                       key="compactS"
                       width='100px'
                       render= {(text, record, index) => {
                         if(record.sum == 1) {
                           return this.numberSum('compactS')
                         } else {
                            return (<input className="prodution_update_progress_input_edit production_number_detail_number" onChange={this.InputChange.bind(this,'compactS',index)} type="number"  value={record.compactS}/>)
                         }
                       }}
                     />
                     <Column
                       title="裁剪数"
                       dataIndex=""
                       key=""
                       width='100px'
                       render= {(text, record, index) => {
                         if(record.sum == 1) {
                           return this.numberSum('compactS')+this.numberSum('addS')
                         } else {
                             return Number(record.totalS) || 0
                         }
                       }}
                     />
                   </ColumnGroup>
                   <ColumnGroup title="M">
                     <Column
                       title="合同数"
                       dataIndex="addM"
                       key="addM"
                       width='100px'
                       render= {(text, record, index) => {
                         if(record.sum == 1) {
                           return this.numberSum('addM')
                         } else {
                            return (<input className="prodution_update_progress_input_edit production_number_detail_number" onChange={this.InputChange.bind(this,'addM',index)} type="number"  value={record.addM}/>)
                         }
                       }}
                     />
                     <Column
                       title="加裁数"
                       dataIndex="compactM"
                       key="compactM"
                       width='100px'
                       render= {(text, record, index) => {
                         if(record.sum == 1) {
                           return this.numberSum('compactM')
                         } else {
                            return (<input className="prodution_update_progress_input_edit production_number_detail_number" onChange={this.InputChange.bind(this,'compactM',index)} type="number"  value={record.compactM}/>)
                         }
                       }}
                     />
                     <Column
                       title="裁剪数"
                       dataIndex=""
                       key=""
                       width='100px'
                       render= {(text, record, index) => {
                         if(record.sum == 1) {
                           return this.numberSum('compactM')+this.numberSum('addM')
                         } else {
                             return Number(record.totalM) || 0
                         }
                       }}
                     />
                   </ColumnGroup>
                   <ColumnGroup title="L">
                     <Column
                       title="合同数"
                       dataIndex="addL"
                       key="addL"
                       width='100px'
                       render= {(text, record, index) => {
                         if(record.sum == 1) {
                           return this.numberSum('addL')
                         } else {
                            return (<input className="prodution_update_progress_input_edit production_number_detail_number" onChange={this.InputChange.bind(this,'addL',index)} type="number"  value={record.addL}/>)
                         }
                       }}
                     />
                     <Column
                       title="加裁数"
                       dataIndex="compactL"
                       key="compactL"
                       width='100px'
                       render= {(text, record, index) => {
                         if(record.sum == 1) {
                           return this.numberSum('compactL')
                         } else {
                            return (<input className="prodution_update_progress_input_edit production_number_detail_number" onChange={this.InputChange.bind(this,'compactL',index)} type="number"  value={record.compactL}/>)
                         }
                       }}
                     />
                     <Column
                       title="裁剪数"
                       dataIndex=""
                       key=""
                       width='100px'
                       render= {(text, record, index) => {
                         if(record.sum == 1) {
                           return this.numberSum('compactL')+this.numberSum('addL')
                         } else {
                           return Number(record.totalL) || 0
                         }
                       }}
                     />
                   </ColumnGroup>
                   <ColumnGroup title="XL">
                     <Column
                       title="合同数"
                       dataIndex="addXL"
                       key="addXL"
                       width='100px'
                       render= {(text, record, index) => {
                         if(record.sum == 1) {
                           return this.numberSum('addXL')
                         } else {
                            return (<input className="prodution_update_progress_input_edit production_number_detail_number" onChange={this.InputChange.bind(this,'addXL',index)} type="number"  value={record.addXL}/>)
                         }
                       }}
                     />
                     <Column
                       title="加裁数"
                       dataIndex="compactXL"
                       key="compactXL"
                       width='100px'
                       render= {(text, record, index) => {
                         if(record.sum == 1) {
                           return this.numberSum('compactXL')
                         } else {
                            return (<input className="prodution_update_progress_input_edit production_number_detail_number" onChange={this.InputChange.bind(this,'compactXL',index)} type="number"  value={record.compactXL}/>)
                         }
                       }}
                     />
                     <Column
                       title="裁剪数"
                       dataIndex=""
                       key=""
                       width='100px'
                       render= {(text, record, index) => {
                         if(record.sum == 1) {
                           return this.numberSum('compactXL')+this.numberSum('addXL')
                         } else {
                           return Number(record.totalXL) || 0
                         }
                       }}
                     />
                   </ColumnGroup>
                   <ColumnGroup title="2XL">
                     <Column
                       title="合同数"
                       dataIndex="add2XL"
                       key="add2XL"
                       width='100px'
                       render= {(text, record, index) => {
                         if(record.sum == 1) {
                           return this.numberSum('add2XL')
                         } else {
                            return (<input className="prodution_update_progress_input_edit production_number_detail_number" onChange={this.InputChange.bind(this,'add2XL',index)} type="number"  value={record.add2XL}/>)
                         }
                       }}
                     />
                     <Column
                       title="加裁数"
                       dataIndex="compact2XL"
                       key="compact2XL"
                       width='100px'
                       render= {(text, record, index) => {
                         if(record.sum == 1) {
                           return this.numberSum('compact2XL')
                         } else {
                            return (<input className="prodution_update_progress_input_edit production_number_detail_number" onChange={this.InputChange.bind(this,'compact2XL',index)} type="number"  value={record.compact2XL}/>)
                         }
                       }}
                     />
                     <Column
                       title="裁剪数"
                       dataIndex=""
                       key=""
                       width='100px'
                       render= {(text, record, index) => {
                         if(record.sum == 1) {
                           return this.numberSum('compact2XL')+this.numberSum('add2XL')
                         } else {
                           return Number(record.total2XL) || 0
                         }
                       }}
                     />
                   </ColumnGroup>
                   <ColumnGroup title="3XL">
                     <Column
                       title="合同数"
                       dataIndex="add3XL"
                       key="add3XL"
                       width='100px'
                       render= {(text, record, index) => {
                         if(record.sum == 1) {
                           return this.numberSum('add3XL')
                         } else {
                            return (<input className="prodution_update_progress_input_edit production_number_detail_number" onChange={this.InputChange.bind(this,'add3XL',index)} type="number"  value={record.add3XL}/>)
                         }
                       }}
                     />
                     <Column
                       title="加裁数"
                       dataIndex="compact3XL"
                       key="compact3XL"
                       width='100px'
                       render= {(text, record, index) => {
                         if(record.sum == 1) {
                           return this.numberSum('compact3XL')
                         } else {
                            return (<input className="prodution_update_progress_input_edit production_number_detail_number" onChange={this.InputChange.bind(this,'compact3XL',index)} type="number"  value={record.compact3XL}/>)
                         }
                       }}
                     />
                     <Column
                       title="裁剪数"
                       dataIndex=""
                       key=""
                       width='100px'
                       render= {(text, record, index) => {
                         if(record.sum == 1) {
                           return this.numberSum('compact3XL')+this.numberSum('add3XL')
                         } else {
                          return Number(record.total3XL) || 0
                         }
                       }}
                     />
                   </ColumnGroup>
                   <ColumnGroup title="4XL">
                     <Column
                       title="合同数"
                       dataIndex="add4XL"
                       key="add4XL"
                       width='100px'
                       render= {(text, record, index) => {
                         if(record.sum == 1) {
                           return this.numberSum('add4XL')
                         } else {
                            return (<input className="prodution_update_progress_input_edit production_number_detail_number" onChange={this.InputChange.bind(this,'add4XL',index)} type="number"  value={record.add4XL}/>)
                         }
                       }}
                     />
                     <Column
                       title="加裁数"
                       dataIndex="compact4XL"
                       key="compact4XL"
                       width='100px'
                       render= {(text, record, index) => {
                         if(record.sum == 1) {
                           return this.numberSum('compact4XL')
                         } else {
                            return (<input className="prodution_update_progress_input_edit production_number_detail_number" onChange={this.InputChange.bind(this,'compact4XL',index)} type="number"  value={record.compact4XL}/>)
                         }
                       }}
                     />
                     <Column
                       title="裁剪数"
                       dataIndex=""
                       key=""
                       width='100px'
                       render= {(text, record, index) => {
                         if(record.sum == 1) {
                           return this.numberSum('compact4XL')+this.numberSum('add4XL')
                         } else {
                           return Number(record.total4XL) || 0
                         }
                       }}
                     />
                   </ColumnGroup>
                   <ColumnGroup title="5XL">
                     <Column
                       title="合同数"
                       dataIndex="add5XL"
                       key="add5XL"
                       width='100px'
                       render= {(text, record, index) => {
                         if(record.sum == 1) {
                           return this.numberSum('add5XL')
                         } else {
                            return (<input className="prodution_update_progress_input_edit production_number_detail_number" onChange={this.InputChange.bind(this,'add5XL',index)} type="number"  value={record.add5XL}/>)
                         }
                       }}
                     />
                     <Column
                       title="加裁数"
                       dataIndex="compact5XL"
                       key="compact5XL"
                       width='100px'
                       render= {(text, record, index) => {
                         if(record.sum == 1) {
                           return this.numberSum('compact5XL')
                         } else {
                            return (<input className="prodution_update_progress_input_edit production_number_detail_number" onChange={this.InputChange.bind(this,'compact5XL',index)} type="number"  value={record.compact5XL}/>)
                         }
                       }}
                     />
                     <Column
                       title="裁剪数"
                       dataIndex=""
                       key=""
                       width='100px'
                       render= {(text, record, index) => {
                         if(record.sum == 1) {
                           return this.numberSum('compact5XL')+this.numberSum('add5XL')
                         } else {
                           return Number(record.total5XL) || 0
                         }
                       }}
                     />
                 </ColumnGroup>
                   <Column
                     title="裁剪总数"
                     dataIndex="age"
                     key="age"
                     width='100px'
                     fixed= 'right'
                     render= {(text, record, index) => {
                       if (record.sum == 1) {
                         return this.numberSum('itemTotal')
                       } else {
                         return record.itemTotal
                       }
                     }}
                   />
                   <Column
                     title="备注"
                     dataIndex="remark"
                     key="remark"
                     width='100px'
                     fixed= 'right'
                     render= {(text, record, index) => {
                       if (record.sum == 1) {
                         return ''
                       } else {
                         return (<input title={record.remark} className="prodution_update_progress_input_edit" onChange={this.InputChange.bind(this,'remark',index)} type="text"  value={record.remark}/>)
                       }
                     }}
                   />
                   <Column
                     title=""
                     key=""
                     width='100px'
                     fixed= 'right'
                     render= {(text, record, index) => {
                         if (index == this.state.dataSource.length-2) {
                           if (index != 0) {
                             return (
                               <span>
                                 <a className="order_from_sp_add" onClick={this.handleAdd}></a>&nbsp;
                                 <a className="order_from_sp_minus" onClick={this.onDelete.bind(this, index,record.numberDetailId)}></a>
                               </span>
                             )
                           } else {
                             return (<a className="order_from_sp_add" onClick={this.handleAdd}></a>)
                           }
                         } else if (index == this.state.dataSource.length-1) {
                           return ''
                         } else {
                           return (
                                <a className="order_from_sp_minus" onClick={this.onDelete.bind(this, index,record.numberDetailId)}></a>
                           )
                         }
                     }}
                   />
                 </Table>
                <AddImgModal ref={'addimg'} showImg={this.showImg.bind(this)} key={ReactKey.key}/>
                <div className="packagSteps_footer"><Button onClick={this.SaveNumberClick.bind(this)}>保存</Button></div>
            </div>
        )
    }
}
